package com.mvp.widget.localclick;

import android.support.annotation.NonNull;
import android.text.TextPaint;
import android.text.style.ClickableSpan;
import android.view.View;

/**
 * Created by zhangyuncai on 2019/1/7.
 * 局部点击效果
 */
public class LocalClickable extends ClickableSpan {
    private View.OnClickListener listener;
    private int localTextColor;


    public LocalClickable(View.OnClickListener listener, int localTextColor) {
        this.listener = listener;
        this.localTextColor = localTextColor;
    }

    @Override
    public void onClick(@NonNull View widget) {
        listener.onClick(widget);
    }

    @Override
    public void updateDrawState( @NonNull TextPaint ds) {
        ds.setColor(localTextColor);
        ds.setUnderlineText(false);
    }
}
